package bounce;

import junit.framework.TestCase;

/**
 * Test cases to test RectangleTextShape.
 * 
 * @author Ken Neth Yeoh
 *
 */

public class TestRectangleTextShape extends TestCase {
	private MockPainter painter;
	
	public void setUp() {
		painter = new MockPainter();
	}
	
	public void testShapeWithBounceOffLeft() {
		String message = "Hello world!";
		RectangleTextShape shape = new RectangleTextShape(10, 50, -15, 15, 40, 40, message);
		shape.paint(painter);
		shape.move(1000,1000);
		shape.paint(painter);
		shape.move(1000,1000);
		shape.paint(painter);
		assertEquals("(rectangle 10,50,40,40)(draw text " + message + ")(rectangle 0,65,40,40)(draw text " + message + ")(rectangle 15,80,40,40)(draw text " + message + ")", painter.toString());
	}
	
	public void testShapeWithBounceOffRight() {
		String message = "Hello world!";
		RectangleTextShape shape = new RectangleTextShape(950, 50, 15, 15, 40, 40, message);
		shape.paint(painter);
		shape.move(1000,1000);
		shape.paint(painter);
		shape.move(1000,1000);
		shape.paint(painter);
		assertEquals("(rectangle 950,50,40,40)(draw text " + message + ")(rectangle 960,65,40,40)(draw text " + message + ")(rectangle 945,80,40,40)(draw text " + message + ")", painter.toString());
	}
	
	public void testShapeWithBounceOffTop() {
		String message = "Hello world!";
		RectangleTextShape shape = new RectangleTextShape(50, 10, 15, -15, 40, 40, message);
		shape.paint(painter);
		shape.move(1000,1000);
		shape.paint(painter);
		shape.move(1000,1000);
		shape.paint(painter);
		assertEquals("(rectangle 50,10,40,40)(draw text " + message + ")(rectangle 65,0,40,40)(draw text " + message + ")(rectangle 80,15,40,40)(draw text " + message + ")", painter.toString());
	}
	
	public void testShapeWithBounceOffBottom() {
		String message = "Hello world!";
		RectangleTextShape shape = new RectangleTextShape(50, 950, 15, 15, 40, 40, message);
		shape.paint(painter);
		shape.move(1000,1000);
		shape.paint(painter);
		shape.move(1000,1000);
		shape.paint(painter);
		assertEquals("(rectangle 50,950,40,40)(draw text " + message + ")(rectangle 65,960,40,40)(draw text " + message + ")(rectangle 80,945,40,40)(draw text " + message + ")", painter.toString());
	}
}
